<%@ page language="java" pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<%@ include file="/pub/head_latest.inc"%>
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
	<meta charset="utf-8" />
	<title>${logoName}</title>
	<meta name="description" content="overview &amp; stats" />
	<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0" />

	<!-- bootstrap & fontawesome -->
	<link rel="stylesheet" href="${baseURL}/css/bootstrap.min.css${sv}" />
	<link rel="stylesheet" href="${baseURL}/assets/css/ace-fonts.css${sv}" />
	<link rel="stylesheet" href="${baseURL}/assets/css/ace-head.min.css${sv}" />
	<link href="${baseURL}/themes/plugin/ace/ace-sidebar.css${sv}" rel="stylesheet" type="text/css" />
	<link href="${baseURL}/themes/blue/css/content.css${sv}" rel="stylesheet" type="text/css" />
	<link rel="stylesheet" href="${baseURL}/js/mCustomScrollbar/jquery.mCustomScrollbar.css${sv}" />
	<script src="${baseURL}/js/mCustomScrollbar/jquery.mCustomScrollbar.concat.min.js${sv}"></script>
	<!-- ace settings handler -->
	<script src="${baseURL}/themes/plugin/ace/ace-extra.min.js${sv}"></script>
	<link href="${baseURL}/themes/plugin/scrollbar/jquery.mCustomScrollbar.css${sv}" rel="stylesheet" type="text/css" />
	<script src="${baseURL}/themes/plugin/ligerUI_latest/lib/ligerUI/js/plugins/ligerTab.js${sv}" type="text/javascript"></script>
	<style>
	    body,html{
	    	font-family: PingFang SC, "Helvetica Neue",Helvetica,Arial,sans-serif;
	    }
		.mCustomScrollBox, .mCSB_container{
			overflow: visible;
		}
		.main-content{
			margin:0;
		}
	</style>
</head>
<body class="no-skin">
    <%@ include file="top.jsp" %>
	<div class="main-container" id="main-container">
		<div id="sidebar" class="sidebar responsive-min collapse-rt" position="left">	
			<div id="mCSBSider">
				<c:forEach var="o" items="${menusBean}" varStatus="idx">
					<!-- 一级菜单 -->
         			<ul class="nav nav-list <c:if test='${idx.count != 1}'>hide</c:if>" data-id="${o.id}" data-code="${o.code}">
         				<c:forEach var="c" items="${o.childrens}" varStatus="children">
         				<c:if test="${children.index eq 0}" >
        				<li alt="${c.name}" name="${c.url}">
         				</c:if>
       					<c:if test="${children.index != 0}" >
         				     <li  alt="${c.name}" name="${c.url}" class="">
         				</c:if>
						 <!-- Start -->
               			<a  id="${c.id}" title="${c.name}"  alt="${c.name}"  class="dropdown-toggle" href="javascript:void(0)" name="${c.url}" id="FirstLink_${c.id}" onclick="showContent(this)" >
               				<c:if test="${c.hasChildren}">
               		 			<b class="arrow fa fa-angle-down"></b>
               		 		</c:if>
                			<i class="menu-icon ${c.smallIconPath}"></i> <span class="menu-text"> ${c.name} </span>
                    	</a>
                    	<b class="arrow"></b>
                    	<!--  二级菜单 -->
                    	<c:if test="${c.hasChildren}">
                    		<ul class="submenu" >
                    			<c:forEach var="b" items="${c.childrens}">
                    			<li  alt="${b.name}" id="${b.id}" name="${b.url}" class="">
                    			   <a   id="${b.id}" title="${b.name}"  alt="${b.name}"   name="${b.url}"  class="dropdown-toggle" href="javascript:void(0)" id="SecondLink_${b.id}" onclick="showContent(this)" >
								 	<c:if test="${b.hasChildren}">
								    <i class="menu-icon fa fa-caret-right"></i></c:if>
								      ${b.name}
								      	<c:if test="${b.hasChildren}">
								     <b class="arrow fa fa-angle-down"></b>
								     </c:if>
							         </a>
							   
							    <!--  三级菜单 -->
							         <c:if test="${b.hasChildren}">
							              <b class="arrow"></b>
									    <ul class="submenu">
										  <c:forEach var="d" items="${b.childrens}" varStatus="idx">
									        <li   alt="${d.name}" id="${d.id}" name="${d.url}"  class="">
									             <a id="${d.id}"  title="${d.name}"  alt="${d.name}"  class="dropdown-toggle"  href="#"  name="${d.url}" onclick="showContent(this)" >
									              <c:if test="${d.hasChildren}">
										            <i class="menu-icon fa fa-caret-right"></i>
										            </c:if>
										          ${d.name}
									             </a>
									            
									             <c:if test="${d.hasChildren}">
									              <ul class="submenu">
										 			 <c:forEach var="e" items="${d.childrens}" varStatus="idx">
									             	  <li  alt="${e.name}" id="${e.id}" name="${e.url}"  class="" >
														<a id="${e.id}"  title="${e.name}" alt="${e.name}"  href="#"  name="${e.url}"  onclick="showContent(this)">
														<i class="menu-icon fa fa-caret-right"></i>
														  ${e.name}
														</a>
														<b class="arrow"></b>
													 </li>
													</c:forEach>
												</ul>
									             </c:if>
								              </li>
								         </c:forEach>
								       </ul>
									
									</c:if>
							   </li>
							</c:forEach>
                    		</ul>
						</c:if>
          	    		</li>
	          	    </c:forEach>
	          	        <div class="sidebar-toggle sidebar-collapse" id="sidebar-collapse">
							<i class="ace-icon fa fa-angle-double-left" data-icon1="ace-icon fa fa-angle-double-left" data-icon2="ace-icon fa fa-angle-double-right"></i>
						</div>
	          	    </ul><!-- /.nav.nav-list -->
				</c:forEach>
			</div>
			<div class="collapse-wrap anotherCollapse">
				<div class="sidebar-toggle sidebar-collapse" id="sidebar-collapse">
					<i class="ace-icon fa side-lt" data-icon1="ace-icon fa side-lt" data-icon2="ace-icon fa side-rt"></i>
				</div>
			</div>
		</div><!--/.sidebar -->
		
		<div class="main-content" id="framecenter" position="center">
			<div tabid="home" title="我的工作台" style="height:300px;" icon="fa fa-home">
				<div style="height: 100%;width: 100%;">
					<iframe name="indexFrame" id="indexFrame"  frameborder="0" name="home" id="home" style="width: 100%; height: 100%;" src=""></iframe>
				</div>
				<script>
					<c:if test="${empty indexUrl || (!empty indexUrl && !empty userOwnLayoutId)}">
						$(function(){
							$("#indexFrame").attr("src","${baseURL}/panel/layout/layoutlist/toPanelIndex.do?userOwnLayoutId=${userOwnLayoutId}&isWorkBeanch=${isWorkBeanch}");
						})
					</c:if>
					<c:if test="${!empty indexUrl && empty userOwnLayoutId}">
						$(function(){
							$("#indexFrame").attr("src","${baseURL}/${indexUrl}");
						})
					</c:if>
				</script>
			</div>
		</div>
		<!-- /.main-content -->
	</div><!-- /.main-container -->
	
<!-- ace scripts -->
<script src="${baseURL}/themes/plugin/ace/ace.min.js${sv}"></script>
<script src="${baseURL}/themes/plugin/scrollbar/jquery.mCustomScrollbar.concat.min.js${sv}"></script>

<script type="text/javascript">
/* 定义左侧菜单栏缩小后宽度 */
var leftMenuMin = '43px';
/* 定义左侧菜单栏宽度 */
var leftMenu = '160px' ;
//左侧菜单栏 滚动条
$(window).on("load resize",function(){
	var cheight = $('#main-container').height()-2;
	$("#mCSBSider").css({"height":cheight+"px","max-height":cheight+"px"});
	$("#mCSBSider").mCustomScrollbar({
		scrollInertia: 10,
		axis: "y",
		theme:"minimal-dark",
		scrollbarPosition: "inside"
	});
});


$(function (){
    //布局
    var layout = $("#main-container").ligerLayout({ leftWidth: parseInt(leftMenu), height: '100%',space:0});
    $(".l-layout-header").remove();
	$(".l-layout-drophandle-left").remove();
	$(".l-layout-left").height($(".main-container").height());
	$(".l-layout-center").height($(".main-container").height());
    var height = $(".l-layout-center").height();
    //Tab
    $("#framecenter").ligerTab({ height: height,contextmenu:false});
    tab = $("#framecenter").ligerGetTabManager();
    
    <c:if test="${!empty SYS_MENU_COLOR}">
    $(".no-skin .nav-list>li").css("cssText","border-top:1px solid ${SYS_MENU_COLOR}")
    $(".no-skin .nav-list>li>a").css("cssText","background:${SYS_MENU_COLOR} !important")
    </c:if>
});

/* 使用了linger,会自动包裹一层外衣,没法通过子元素类控制父元素,需要通过js控制 */
$('.sidebar-toggle').click(function () {
	/* 定义偏移距离,菜单收缩之后linger需要重新计算布局 */
	var distance = parseInt(leftMenu) - parseInt(leftMenuMin);
	if (!$('#sidebar').hasClass('menu-min')) {
		$('.l-layout-left').css("width", leftMenuMin)
		$('.l-layout-center').css({"left":"0", "margin-left":leftMenuMin})
	} else {
		$('.l-layout-left').css("width", leftMenu)
		$('.l-layout-center').css({"left":leftMenu, "margin-left":0})
		distance = - distance
	}
	$('.l-layout-center').css('width', parseInt($('.l-layout-center').css('width')) +  distance + 'px' )
	/* 控制两个收缩框同步展示 */
	if (($('#sidebar-collapse i').hasClass('fa-angle-double-left')) && 
		($('#sidebar-collapse i').hasClass('side-lt'))) {
		$('#sidebar-collapse .fa-angle-double-left').addClass('fa-angle-double-right').removeClass('fa-angle-double-left')
		$('#sidebar-collapse .side-lt').addClass('side-rt').removeClass('side-lt')		
	} else {
		$('#sidebar-collapse .fa-angle-double-right').addClass('fa-angle-double-left').removeClass('fa-angle-double-right')
		$('#sidebar-collapse .side-rt').addClass('side-lt').removeClass('side-rt')
	}
})

       	
/* 切换头部一级菜单 */
function changeTab($obj, name){
    var sublen = $('[data-id='+ name +']').find('li').length;
    // 没有子菜单时，将菜单视为功能菜单，进行跳转
    if (sublen == 0) {
        var text = $obj.find('span').text();
        var f_url = "${baseURL}/frame/index/forward.do?menuId="+name;
        tab.addTabItem({ tabid : name,text: text, url: f_url });
        return;
	}

	// 展开子菜单
	if(!$('.nav-list').hasClass('hide')) {
		$('.nav-list').removeClass('hide')
	} else {
		$('.nav-list').addClass('hide')
	}
	$('[data-id='+ name +']').removeClass('hide')
	return false
}


function showContent(obj){
	var $obj = $(obj)
	/* if(obj.name!=""&&obj.name!=null&&obj.name!="undefined"&&obj.name.indexOf("http") == 0){
  	 	$("#contentFrame").attr("src", obj.name );
   	}else if(obj.name!=""&&obj.name!=null&&obj.name!="undefined"){
 		var f_url = "${baseURL}/frame/index/forward.do?menuId="+obj.id;
  	 	$("#contentFrame").attr("src", f_url );
 	} */
 	 if ($obj.siblings(".submenu").size() == 0) {
 		f_addMenuTab($obj.attr("id"), $obj.attr("alt"));
 	 }
}
//当前访问菜单-字体加粗
function highlightMenu(){
	var fmenus = $('#sidebar').find('.nav-list>li');//一级菜单
	fmenus.click(function(){
		if($(this).hasClass('hsub')){
			var smenus = $(this).find('.submenu>li');
			smenus.click(function(){
				/* 清除其他已展开(二级展示三级) */
				if(!$(this).hasClass('hsub')){
					smenus.removeClass('open');
				}
				$(this).addClass('open');
			})
		}else{
			/* 这一块逻辑是实现点击无子元素的li块逻辑 */
			/* $(this).siblings().removeClass('open');
			$(this).siblings().find('.submenu').removeClass('nav-show').addClass('nav-hide').hide(150);
			$(this).addClass('open'); */
		}
	})
};

function showMenu(menuId){
	$(".nav-list").hide();
	$(".nav-list").each(function(){
		if($(this).attr("data-id") == menuId){
			$(this).show();
			$(this).removeClass("hide");
			
			if($(this).attr("data-code") == "home"){
				$("#contentFrame").src("${baseURL}${indexUrl}");
			}
			var $a = $(this).find('a');
			if ($a.length == 1) {
				$a.click();
			}
			return false;
		}
	})
}

$(function (){
	highlightMenu();
});

function f_heightChanged(options){
    if (tab) {
       tab.addHeight(options.diff);    	
    }
}

//update by Lin 2014愚人节
function f_addTab(tabid,text, url){ 
	if(f_isTabExist(tabid)){
		f_closeTab(tabid);
	}
    tab.addTabItem({ tabid : tabid,text: text, url: url });
} 

//add by Lin 2014愚人节
function f_isTabExist(tabid){ 	
	return tab.isTabItemExist(tabid);
} 

function f_reloadTab(){ 
	tab.reload(tabid);
} 

function f_closeTab(tabid){ 
	tab.removeTabItem(tabid);
} 
//end add by Lin

function f_addMenuTab(tabid,text,name){ 
	//通过后台组装地址转发
	var uri = "";
	var f_url = "${baseURL}/frame/index/forward.do?menuId="+tabid;
	if(tab.isTabItemExist(name)){
		tab.selectTabItem(name);
		tab.reload(name);
		uri = "?tab="+name;
	}else if(tab.isTabItemExist(tabid)){
		tab.selectTabItem(tabid);
		tab.reload(tabid);
		uri = "?tab="+tabid;
	} else{
		if(name!=null&&name!=""&&name!="undefined"){
			tab.addTabItem({ tabid : name,text: text, url: f_url });
			uri = "?tab="+name;
		}else{
			tab.addTabItem({ tabid : tabid,text: text, url: f_url });
			uri = "?tab="+tabid;
		}
	}
} 

function reloadParent(){
	parent.window.location.reload(true);
}
 $(function() {
	menu = $.ligerMenu({ top: 100, left: 100, width: 120, 
		items:[
			{ text: '关闭全部', click: removeAll},
			{ line: true },
			{ text: '关闭其他', click: removeOther}
		]
   });
	$("#framecenter").bind("contextmenu", function (e){
		menu.show({ top: e.pageY, left: e.pageX });
	    return false;
	});
		   
	$(document).on("dblclick",".l-tab-links>ul>li",function(){
		if($(this).attr("tabid")!="home"){
			LG.closeCurrentTab($(this).attr("tabid"));
		}
	});
		   
	function removeAll(){
		$(".l-tab-links ul li[tabid]").each(function(){
			if($(this).attr("tabid")!="home") {
				LG.closeCurrentTab($(this).attr("tabid"));
			}
		});
	}
		   
	function removeOther(){
		$(".l-tab-links ul li[tabid]").each(function(){
			if($(this).attr("tabid")=="home" || $(this).attr("class")=="l-selected") return;
			LG.closeCurrentTab($(this).attr("tabid"));
		});
	}
 });
</script>
</body>
</html>